# create the enzyme
import pygame

class Enzyme(pygame.sprite.Sprite):
    def __init__(self,pos,screen_height):
        super().__init__()
        file_path = '../graphics/enzyme/enzyme.png'
        self.image = pygame.image.load(file_path).convert_alpha()
        self.rect = self.image.get_rect(center = pos)
        
        self.height_y_constraint = screen_height
        self.direction = pygame.math.Vector2(0,0)

    # kill the enzyme when outside the screen
    def destroy(self):
        if self.rect.y <= -50 or self.rect.y >= self.height_y_constraint +50:
            self.kill()

    def move(self):
        self.rect.y += self.speed

    # this function may have no use
    def reverse_image(self):
        if self.speed <= 0:
            self.image = pygame.transform.flip(self.image,True,False)
    
    def update(self,shift):
        self.rect.x += shift
        self.move()
        self.destroy()